﻿#region NeoPatterns
// 
// NeoPatterns framework is released under LGPLv3 license.
// See http://www.opensource.org/licenses/lgpl-3.0.html for more details.
// 
// Please visit http://neopatterns.wikidot.com for more information about NeoPatterns
// 
// Copyright (c) Pascal Craponne 2008
// 
#endregion

using System;
using MetaConsole.Client;
using MetaConsole.Contract;
using MetaConsole.Service;
using NeoPatterns.Core;
using NeoPatterns.Setup.MetaAssembly;

// This is a sample console application, with
// - a client (SimpleClient)
// - a service (SimpleService) under the interface IService
// We have 4 assemblies:
// - Client, holding the SimpleClient
// - Service, holding the SimpleService
// - Contract, holding IService
// - MetaAssembly, which is the entry point and configuration

namespace MetaConsole.MetaAssembly
{
    class Program
    {
        static void Main(string[] args)
        {
            MetaAssemblyLoader.Run();
        }
    }

    [MetaClass]
    class MetaSimpleClient: MetaConfiguration
    {
        [MetaInitializer("SimpleClient")]
        static void Initialize(SimpleClient simpleClient)
        {
            simpleClient.Service = Ref<IService>("SimpleService");
        }
    }

    [MetaClass]
    class MetaSimpleService: MetaConfiguration
    {
        [MetaCreator("SimpleService")]
        static SimpleService Ctor()
        {
            return new SimpleService();
        }
    }

    [MetaClass]
    class MetaStartup: MetaConfiguration
    {
        [MetaEntry]
        static void Startup()
        {
            var client = Ref<SimpleClient>("SimpleClient");
            client.Entry();
        }
    }
}
